

     
var a = '2020-01-01 08:08:08';
var b = '2022-07-31 08:08:08';
var c = new Date(a).getTime();
var d = new Date(b).getTime();
var e = d - c;
var f = Math.round(Math.random()*e)+c;

function timestampToTime(timestamp) {
  var date = new Date(timestamp);//时间戳为10位需*1000，时间戳为13位的话不需乘1000
  var Y = date.getFullYear() + '-';
  var M = (date.getMonth()+1 < 10 ? '0'+(date.getMonth()+1) : date.getMonth()+1) + '-';
  var D = date.getDate() + ' ';
  var h = date.getHours() + ':';
  var m = date.getMinutes() + ':';
  var s = date.getSeconds();
  return Y+M+D+h+m+s;
}
let ttt= timestampToTime(f);

let str = "2000-05-31";
let array = str.slice('-');
console.log(new Date(str).getTime());

